package com.xx.springboot.service.impl;

import com.xx.springboot.entity.Category;
import com.xx.springboot.entity.CommonResult;
import com.xx.springboot.mapper.CategoryMapper;
import com.xx.springboot.service.ICategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaoxiunique
 * @since 2018-08-06
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService {

    @Autowired
    private CategoryMapper categoryMapper;
    /**
     * 增加类型
     *
     * @param categoryName
     * @return
     */
    @Override
    public boolean add(String categoryName) {
        Category category = new Category();
        category.setName(categoryName);
        category.setStatus(1);
        category.setCreateTime(new Date(System.currentTimeMillis()));

        Integer res = categoryMapper.insert(category);
        return res == 1;
    }
}
